package Operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class  BrrowOperation implements IOperation {

    @Override
    public void work(BookList books) {
        System.out.println("借阅图书");
        System.out.println("请输入想要借阅的图书");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.next();
        for (int i=0;i<books.getUserSize();i++) {
            Book book= books.getBooks(i);//将返回的引用给book
            if(book.getName().equals(name))//用book去调用Book类的getName
            {
                if(book.isBorrowde()) {
                    System.out.println("该书被借出");
                }
                else {
                    book.setBorrowde(true);
                    System.out.println("借书成功");
                }
                return;
            }
        }
        System.out.println("没有找到该书！ ");
    }
}
